<template>
  <div>
    <van-goods-action>
      <van-goods-action-icon
        :icon="!isCollected ? 'star-o' : 'star'"
        :text="!isCollected ? '未收藏' : '收藏'"
        :color="!isCollected ? '#333' : 'red'"
        @click="isCollected = !isCollected"
      />
      <van-goods-action-icon
        icon="cart-o"
        text="购物车"
        :badge="goodsCount"
        color="#333"
      />
      <van-goods-action-button
        type="danger"
        text="立即购买"
        @click="handleClick"
      />
      <van-goods-action-button
        type="warning"
        text="加入购物车"
        @click="goToCart"
      />
    </van-goods-action>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isCollected: false,
    };
  },
  methods: {
    // 立即购买
    handleClick() {
      this.$toast("功能未开放");
    },
    // 加入购物车
    goToCart() {
      this.$emit("goToCart");
    },
  },
  props: ["goodsCount"],
};
</script>

<style>
.van-goods-action {
  z-index: 9999;
}
</style>